<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        .box {
            width: 100px;
            height: 100px;
        }

        .active {
            width: 100px;
            height: 100px;
            background-color: red;
        }

        .danger {
            color: blue;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- active 是一个样式 isActive 是个变量 -->
        <div :class="{active: isActive, danger: isError}" class="box">
            hello vue.
        </div>
        <button @click="active">激活按钮</button>

        <div :class="[active_2, danger_2]" class="box">
            hello vue.
        </div>

        <!-- 使用组件\绑定样式 -->
        <my-component :class="[active_2, danger_2]"></my-component>

        <!-- 内联样式 -->
        <div :style="{color: fontColor, fontSize}">
            内联样式
        </div>

        <div :style="myStyle">
            内联样式-myStyle
        </div>

        <div :style="[myStyle, myStyle2]">
            内联样式-myStyle2
        </div>

    </div>
    <script src="https://unpkg.com/vue@next"></script>
    <script>

        let myComponent = {
            template: `<p class="foo bar">Hi!</p>`
        }

        const App = {
            data() {
                return {
                    isActive: false,
                    isError: false,
                    active_2: 'active',
                    danger_2: 'danger',
                    fontColor: 'green',
                    fontSize: '50px',
                    myStyle: {
                        color: 'green',
                        fontSize: '80px'
                    },
                    myStyle2: {
                        background: 'black',
                    }
                }
            },
            methods: {
                active() {
                    this.isActive = !this.isActive
                    this.isError = !this.isError
                }
            }
        }

        const vue = Vue.createApp(App)
        vue.component("my-component", myComponent)
        vue.mount("#app")
    </script>
</body>

</html>